import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
import {h} from "vue";
import {Tag} from "ant-design-vue";
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '合同编号',
    align:"center",
    dataIndex: 'ontractNumber'
   },
   {
    title: '合同名称',
    align:"center",
    dataIndex: 'contractName'
   },
   {
    title: '客户名称',
    align:"center",
    sorter: true,
    dataIndex: 'customerName'
   },
   {
    title: '行政区域',
    align:"center",
    dataIndex: 'homeAddress',
   },
   {
    title: '详细地址',
    align:"center",
    dataIndex: 'address'
   },
   {
    title: '联系人',
    align:"center",
    dataIndex: 'contacts'
   },
   {
    title: '联系电话',
    align:"center",
    dataIndex: 'telephone'
   },
   {
    title: '签约时间',
    align:"center",
    dataIndex: 'signingTime',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
   {
    title: '合同状态',
    align:"center",
    dataIndex: 'contractStatus_dictText'
   },
   {
    title: '合同生效时间',
    align:"center",
    dataIndex: 'effectiveTime',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
   {
    title: '合同终止时间',
    align:"center",
    dataIndex: 'endTime',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
   {
    title: '合同金额',
    align:"center",
    dataIndex: 'contractAmount'
   },
   {
    title: '待回款金额',
    align:"center",
    dataIndex: 'collectionAmount'
   },
   {
    title: '合同描述',
    align:"center",
    dataIndex: 'contractDescription',
   },
   {
    title: '合同附件',
    align:"center",
    dataIndex: 'attachment',
   },
  {
    title: '所属销售',
    align:"center",
    dataIndex: 'createBy'
  },
/*   {
    title: '所属销售',
    align:"center",
    dataIndex: 'belongingSales_dictText'
   },*/
   {
    title: '审批处理人',
    align:"center",
    dataIndex: 'processInitiator'
   },
   {
    title: '流程状态',
    align:"center",
    dataIndex: 'processStatus_dictText'
   },
   // {
   //  title: '流程进展',
   //  align:"center",
   //  dataIndex: 'processProgress'
   // },
   // {
   //  title: '流程启动时间',
   //  align:"center",
   //  dataIndex: 'processStartTime',
   //   show: false
   // },
   // {
   //  title: '流程结束时间',
   //  align:"center",
   //  dataIndex: 'processEndTime'
   // },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "合同编号",
      field: "ontractNumber",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "合同名称",
      field: "contractName",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "客户名称",
      field: "customerName",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "联系人",
      field: "contacts",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "联系电话",
      field: "telephone",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "合同状态",
      field: "contractStatus",
      component: 'JSelectMultiple',
      componentProps:{
          dictCode:"contract_status"
      },
      //colProps: {span: 6},
 	},
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '合同编号',
    field: 'ontractNumber',
    component: 'Input',
    labelWidth: 150,
    colProps: {span: 24},
  },
  {
    label: '合同名称',
    field: 'contractName',
    component: 'Input',
    labelWidth: 150,
    colProps: {span: 24},
  },
  {
    label: '选择客户信息',
    field: 'popup',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
      const {setFieldsValue} = formActionType;
      return{
        setFieldsValue:setFieldsValue,
        //online报表编码
        code:"customer_info",
        //是否为多选
        multi:false,
        //字段配置
        fieldConfig: [
          { source: 'id', target: 'customerId' },
          { source: 'customer_name', target: 'customerName' },
          { source: 'contacts', target: 'contacts' },
          { source: 'contact_number', target: 'telephone' },
          { source: 'address', target: 'address' },
          { source: 'home_address', target: 'homeAddress' },
        ],
      }
    },
  },
  {
    label: '客户名称',
    field: 'customerName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入客户名称!'},
          ];
     },
    // dynamicDisabled:true,
  },
  {
    label: '行政区域',
    field: 'homeAddress',
    // defaultValue: "520000,522600,522601",
    defaultValue: ['520000', '522600', '522601'],
    component: 'JAreaLinkage',
    // componentProps: {
    //   saveCode: 'region',
    // },
    // dynamicDisabled:true,
  },
  {
    label: '详细地址',
    field: 'address',
    component: 'Input',
    // dynamicDisabled:true,
  },
  {
    label: '联系人',
    field: 'contacts',
    component: 'Input',
    // dynamicDisabled:true,
  },
  {
    label: '联系电话',
    field: 'telephone',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
          ];
     },
    // dynamicDisabled:true,
  },
  {
    label: '签约时间',
    field: 'signingTime',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入签约时间!'},
          ];
     },
  },
  {
    label: '合同生效时间',
    field: 'effectiveTime',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
  },
  {
    label: '合同终止时间',
    field: 'endTime',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
  },
  {
    label: '合同金额',
    field: 'contractAmount',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入合同金额!'},
          ];
     },
  },
  {
    label: '合同描述',
    field: 'contractDescription',
    component: 'JEditor',
    labelWidth: 150,
    colProps: {span: 24},
  },
  {
    label: '合同附件',
    field: 'attachment',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '所属销售',
    field: 'belongingSales',
    component: 'JSelectUser',
    componentProps:{
       labelKey:'realname',
      isRadioSelection:true
     },
    show: false,
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false,
	},
];

//子表列表数据
export const xcbdCollectionRecordColumns: BasicColumn[] = [
    {
        title: '订单号',
        align:"center",
        dataIndex: 'orderNumber'
    },
   {
    title: '收款日期',
    align:"center",
    dataIndex: 'collectionDate',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
   {
    title: '款项类型',
    align:"center",
    dataIndex: 'paymentType_dictText'
   },
   {
    title: '收款金额',
    align:"center",
    dataIndex: 'amountCollected'
   },
   {
    title: '付款方式',
    align:"center",
    dataIndex: 'paymentMethod_dictText'
   },
    {
        title: '扫码支付',
        align:"center",
        width:"100px",
        dataIndex: 'scanCodePayUrl',
    },
    {
        title: '交易状态',
        align:"center",
        dataIndex: 'tradeState'
    },
    {
        title: '交易状态描述',
        align:"center",
        dataIndex: 'tradeStateDesc'
    },
   {
    title: '收款人',
    align:"center",
    dataIndex: 'createBy'
   },
   {
    title: '收款凭证',
    align:"center",
    dataIndex: 'receiptVoucher',
   },
   {
    title: '到账状态',
    align:"center",
    sorter: true,
    dataIndex: 'receiptStatus_dictText'
   },
   {
    title: '当前流程处理人',
    align:"center",
    dataIndex: 'processInitiator'
   },
   {
    title: '流程状态',
    align:"center",
    dataIndex: 'processStatus'
   },
    /* {
     title: '流程启动时间',
     align:"center",
     dataIndex: 'processStartTime'
    },
    {
     title: '流程结束时间',
     align:"center",
     dataIndex: 'processEndTime'
    },*/
];
//查询数据
export const searchCollectionRecordFormSchema: FormSchema[] = [
  {
    label: "到账状态",
    field: "receiptStatus",
    component: 'JSelectMultiple',
    componentProps:{
      dictCode:"receipt_status"
    },
    //colProps: {span: 6},
  },
];
//子表表单数据
export const xcbdCollectionRecordFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '支付二维码',
    width:"100px",
    field: 'scanCodePayUrl',
    component: 'JImageUpload',
    colProps: {span: 24},
  },
  {
    label: '合同名称',
    field: 'contractName',
    component: 'Input',
  },
  {
    label: '客户名称',
    field: 'customerName',
    component: 'Input',
  },
  {
    label: '联系人',
    component: 'Input',
    field: 'contacts'
  },
  {
    label: '联系电话',
    component: 'Input',
    field: 'telephone'
  },
  {
    label: '收款金额',
    field: 'amountCollected',
    component: 'InputNumber',
  },
  {
    label: '付款方式',
    field: 'paymentMethod',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"payment_method"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入付款方式!'},
      ];
    },
  },
  {
    label: '收款人',
    field: 'createBy',
    component: 'Input',
  },
];
//子表列表数据
export const xcbdWorkflowColumns: BasicColumn[] = [
   {
    title: '创建日期',
    align:"center",
    sorter: true,
    dataIndex: 'createTime'
   },
   {
    title: '流程状态',
    align:"center",
    dataIndex: 'status'
   },
   {
    title: '流程内容',
    align:"center",
    dataIndex: 'content'
   },
/*   {
    title: '流程用时3',
    align:"center",
    dataIndex: 'processTime'
   },*/
];
//子表表单数据
export const xcbdWorkflowFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '创建日期',
    field: 'createTime',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '流程状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"processStatus"
     },
  },
  {
    label: '流程内容',
    field: 'content',
    component: 'Input',
  },
  {
    label: '流程用时',
    field: 'processTime',
    component: 'Input',
  },
];

// 高级查询数据
export const superQuerySchema = {
  ontractNumber: {title: '合同编号',order: 0,view: 'text', type: 'string',},
  contractName: {title: '合同名称',order: 1,view: 'text', type: 'string',},
  customerName: {title: '客户名称',order: 2,view: 'text', type: 'string',},
  homeAddress: {title: '行政区域',order: 3,view: 'pca', type: 'string',},
  address: {title: '详细地址',order: 4,view: 'text', type: 'string',},
  contacts: {title: '联系人',order: 5,view: 'text', type: 'string',},
  telephone: {title: '联系电话',order: 6,view: 'text', type: 'string',},
  signingTime: {title: '签约时间',order: 7,view: 'date', type: 'string',},
  contractStatus: {title: '合同状态',order: 8,view: 'number', type: 'number',dictCode: 'contract_status',},
  effectiveTime: {title: '合同生效时间',order: 9,view: 'date', type: 'string',},
  endTime: {title: '合同终止时间',order: 10,view: 'date', type: 'string',},
  contractAmount: {title: '合同金额',order: 11,view: 'number', type: 'number',},
  collectionAmount: {title: '待回款金额',order: 12,view: 'number', type: 'number',},
  contractDescription: {title: '合同描述',order: 13,view: 'umeditor', type: 'string',},
  attachment: {title: '合同附件',order: 14,view: 'file', type: 'string',},
  belongingSales: {title: '所属销售',order: 15,view: 'sel_user', type: 'string',},
  processInitiator: {title: '流程发起人',order: 16,view: 'text', type: 'string',},
  processStatus: {title: '流程状态',order: 17,view: 'text', type: 'string',},
  processProgress: {title: '流程进展',order: 18,view: 'text', type: 'string',},
  processStartTime: {title: '流程启动时间',order: 19,view: 'datetime', type: 'string',},
  processEndTime: {title: '流程结束时间',order: 20,view: 'datetime', type: 'string',},
};
